<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>

        function Super(name) {
            this.name = name;
            this.letters = ['a', 'b'];
        }

        Super.prototype.sayName = function () {
            alert(this.name);
        }

        function Sub(name, age) {
            // 继承属性
            Super.call(this, name);
            this.age = age;
        }

        // 继承方法
        Sub.prototype = new Super();

        Sub.prototype.sayAge = function () {
            alert(this.age);
        }

        var instance1 = new Sub('Rick', 23);
        instance1.letters.push('c');
        console.log(instance1.letters); // "a", "b", "c"
        instance1.sayName();  // "Rick"
        instance1.sayAge(); // 23


        var instance2 = new Sub('Morty', 12);
        console.log(instance2.letters); // "a", "b"
        instance2.sayName();  // "Morty"
        instance2.sayAge(); // 12
    </script>
</head>
<body>
组合继承（常用模式）
</body>
</html>